package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.presentation.controller.admin;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;

import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.presentation.controller.admin.devtypes.DeviceTypeBean;

@ManagedBean(name="deviceTypeInfoBean")
@ViewScoped
public class DeviceTypeInfoBean {
	
	@ManagedProperty(value="#{flash.selectedType}")
	private DeviceTypeBean selected;

	public DeviceTypeBean getSelected() {
		return selected;
	}

	public void setSelected(DeviceTypeBean selected) {
		this.selected = selected;
	}

	public void forwardTypesIfNotSelection(ComponentSystemEvent cse) {
		FacesContext faceContext = FacesContext.getCurrentInstance();
		if (selected == null) {
			faceContext.getApplication().getNavigationHandler().
		handleNavigation(faceContext, null,	"/adminuser/devicetypes?faces-redirect=true");
		}
	}
	
	
}
